package com.witdata.app

import android.content.Intent
import androidx.core.content.FileProvider
import java.io.File

class MainActivity : TauriActivity() {
    fun installApk(apkPath: String) {
        val apkFile = File(apkPath)
        if (!apkFile.exists()) {
            return;
        }
        val intent = Intent(Intent.ACTION_VIEW).apply {
            flags = Intent.FLAG_ACTIVITY_NEW_TASK
        }
        
        val apkUri =
            FileProvider.getUriForFile(
                this,
                "${application.packageName}.provider",
                apkFile
            )
        intent.setDataAndType(apkUri, "application/vnd.android.package-archive")
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
        startActivity(intent)
    } 
}